package ru.averta.notes.dao.impl;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import ru.averta.notes.dao.TagDao;
import ru.averta.notes.domain.Tag;
import ru.averta.notes.domain.User;

@Repository
public class TagDaoImpl extends GenericDaoHibernateImpl<Tag, Long> implements TagDao {

	public Tag findByUserAndTitle(User user, String title) {
		return (Tag) createCriteria()
		.add(Restrictions.eq("title", title))
		.add(Restrictions.eq("user", user))
		.uniqueResult();
	}

}
